﻿@model FinancesViewModel
@{
    ViewBag.Title = "Finances";
    Layout = "~/Views/Shared/WorkerLayout.cshtml";
}

@if (Model != null && Model.Messages.Count() > 0)
{
    foreach(String message in Model.Messages)
    {
        <div class="ResultOk" style="background-image: none; padding: 10px; margin-bottom: 10px;">@message</div>
    }
}

@if (Model != null && Model.LocationsProfits.Count() > 0)
{
    <h2>Zestawienie według punktów odbioru</h2>
    
    <table class="list" style="width: 100%;">
        <thead>
            <tr>
                <td>Nazwa</td>
                <td>Adres</td>
                <td>Miasto</td>
                <td>Łączna liczba nośników</td>
                <td>Zysk zupełny</td>
            </tr>
        </thead>
    @foreach (KeyValuePair<Agencies, float> location in Model.LocationsProfits)
    {
            <tr>
                <td>@location.Key.AgencyName</td>
                <td>@location.Key.AgencyAddress</td>
                <td>@location.Key.AgencyCity</td>
                <td>@location.Key.Discs.Count</td>
                <td>@string.Format("{0:0.00}zł", location.Value)</td>
            </tr>
    }
    </table>
}

@if (Model != null && Model.Hires.Count<Hires>() > 0)
{
    <h2>Poszczególne wypożyczenia</h2>
    
    <table class="list" style="width: 100%;">
        <thead>
            <tr>
                <td>Lokalizacja</td>
                <td>Film</td>
                <td>Nośnik</td>
                <td>Koszt planowany</td>
                <td>Kara</td>
                <td>Koszt zupełny</td>
            </tr>
        </thead>
        @foreach (Hires hire in Model.Hires)
        {
                <tr>
                    <td>@hire.Discs.Agencies.AgencyName</td>
                    <td>@hire.Discs.Movies.MovieTitle</td>
                    <td>@hire.Discs.DiscTypes.DiscTypeName</td>
                    <td>@string.Format("{0:0.00}zł", hire.HirePlanningCost)</td>
                    <td>@string.Format("{0:0.00}zł", hire.HireLateReward.HasValue ? hire.HireLateReward.Value.ToString("0.00") : "-")</td>
                    <td>@string.Format("{0:0.00}zł", hire.HireLateReward + hire.HirePlanningCost)</td>
                 </tr>
        }
    </table>
    
    <div class="pagesNavigation">
        @Html.PageLinks(Model.PagingInfo, x => Url.Action("Finances", new { page = x }))
    </div>
}
else
{
    <p>Aktualnie żaden użytkownik nie wypożycza nośników</p> 
}